package com.nov.multidatasource.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.xa.DruidXADataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;


@Configuration
public class DataSourceConfig {

    @Primary
    @Bean(name = "primaryProperty")
    @ConfigurationProperties(prefix = "spring.datasource.primary")
    public DruidDataSource primaryDataSource() {
        return new DruidDataSource();
    }

    @Bean(name = "secondaryProperty")
    @ConfigurationProperties(prefix = "spring.datasource.secondary")
    public DruidXADataSource secondaryDataSource() {
        return new DruidXADataSource();
    }
}
